
const express = require('express');
const router = express.Router();
const pageController = require('./controller/pageController.js');
const adminUsersController = require('./controller/adminUsersController.js');
const categoriesController = require('./controller/adminCategoriesController.js');
const adminPostsController = require('./controller/adminPostsController.js');
const commentsController = require('./controller/commentsController.js');


// 监听不同的请求
// 返回一个前台主页
router.get('/',(req,res)=>{
  pageController.getIndex(req,res);
});
router.get('/index',(req,res)=>{
  pageController.getIndex(req,res);
});
// 返回后台主页
router.get('/admin',(req,res)=>{
  pageController.getAdminIndex(req,res);
});
router.get('/admin/index',(req,res)=>{
  pageController.getAdminIndex(req,res);
});
router.get('/admin/categories',(req,res)=>{
  pageController.getAdminCategories(req,res);
});
router.get('/admin/login',(req,res)=>{
  pageController.getAdminLogin(req,res);
});
router.get('/admin/comments',(req,res)=>{
  pageController.getAdminComments(req,res);
});
router.get('/admin/password-reset',(req,res)=>{
  pageController.getAdminPasswordReset(req,res);
});
router.get('/admin/post-add',(req,res)=>{
  pageController.getAdminpostAdd(req,res);
});
router.get('/admin/posts',(req,res)=>{
  pageController.getAdminPosts(req,res);
});
router.get('/admin/profile',(req,res)=>{
  pageController.getAdminProfile(req,res);
});
router.get('/admin/setting',(req,res)=>{
  pageController.getAdminSetting(req,res);
});
router.get('/admin/slides',(req,res)=>{
  pageController.getAdminSlides(req,res);
});
router.get('/admin/users',(req,res)=>{
  pageController.getAdminUsers(req,res);
});
router.get('/admin/settings',(req,res)=>{
  pageController.getAdminSettings(req,res);
});
// 统一约定以下滑线
router.post('/admin_do_login',(req,res)=>{
  adminUsersController.adminDoLogin(req,res);
});
router.get('/getNicknameImage',(req,res)=>{
  adminUsersController.getNicknameImage(req,res);
});
router.post('/addNewCategories',(req,res)=>{
  categoriesController.addNewCategories(req,res);
});
router.get('/delCategoriesById',(req,res)=>{
  categoriesController.delCategoriesById(req,res);
});
router.get('/getcategoiesById',(req,res)=>{
  categoriesController.getcategoiesById(req,res);
});
router.post('/editCategories',(req,res)=>{
  categoriesController.editCategories(req,res);
});
router.get('/deletemultiple',(req,res)=>{
  categoriesController.deletemultiple(req,res);
});
router.post('/getPostsPage',(req,res)=>{
  adminPostsController.getPostsPage(req,res);
});
router.get('/delpostsById',(req,res)=>{
  adminPostsController.delpostsById(req,res);
})
router.get('/getCategories',(req,res)=>{
  adminPostsController.getCategories(req,res);
});
router.post('/getPostsByFilter',(req,res)=>{
  adminPostsController.getPostsByFilter(req,res);
});
router.post('/uploadImage',(req,res)=>{
  adminPostsController.uploadImage(req,res);
});
router.post('/newPostAdd',(req,res)=>{
  adminPostsController.newPostAdd(req,res);
});
router.get('/getPostsById',(req,res)=>{
  adminPostsController.getPostsById(req,res);
});
router.post('/editPostsData',(req,res)=>{
  adminPostsController.editPostsData(req,res);
});
router.post('/getCommentsByPage',(req,res)=>{
  commentsController.getCommentsByPage(req,res);
});
router.get('/admin_logout',(req,res)=>{
  adminUsersController.adminLogout(req,res);
});
router.get('/list',(req,res)=>{
  pageController.getList(req,res);
});
router.get('/detail',(req,res)=>{
  pageController.getDetail(req,res);
});
// 获取前台分类数据
router.get('/getNavigation',(req,res)=>{
  categoriesController.getNavigation(req,res);
});
router.get('/hideNavigation',(req,res)=>{
  categoriesController.hideNavigation(req,res);
});
router.get('/showNavigation',(req,res)=>{
  categoriesController.showNavigation(req,res);
});
router.get('/newestPosts',(req,res)=>{
  adminPostsController.newestPosts(req,res);
});
router.get('/getcategoriPost',(req,res)=>{
  adminPostsController.getcategoriPost(req,res);
});
router.get('/getdetailDataById',(req,res)=>{
  adminPostsController.getdetailDataById(req,res);
});

module.exports = router;